<template>
	<view v-if="detail" class="comp_detail">
		<!--轮播图 -->
		<view class="de_banner">
			<swiper class="swiper_list" :duration="600"  :autoplay="false" @change="currentIndex">
				<swiper-item class="swiper_item" v-for="item,index in detail.images" :key="index">
					<view class="item_pos">
						<image class="img" :src="`${item.u}`" mode="widthFix"></image>
					</view>
				</swiper-item>
			</swiper>
			<!-- btn -->
			<view class="tips">
				<view class="selection_text">
					{{detail.selection_text}}
				</view>
				<view class="nums">
					<!-- {{}} -->
					{{current}}/{{totalPic}}
				</view>
			</view>
		</view>
		<!-- 内容区 -->
		<view class="de_content">
			<view class="con_title">
				{{detail.title}}
			</view>
			<view class="con_topic">
				<block v-for="e,i in detail.contents">
					<view class="topic" :style="`color:${e.color};`">
						<image v-if="e.icon" class="img" :src="`${e.icon}`" mode=""></image>
						<view :class="[e.icon == ''?'txt_active txt':'txt']">
							{{e.c}} 
						</view>
					</view>
				</block>
				<!--  -->
				<view class="topic_time">
					<view class="time">
						{{disposeTime}}
					</view>
					<view class="time_dot">
						<view class="collection" v-if="detail.favo_count">
							{{detail.favo_count}}次收藏
						</view>
						<view class="dots" v-if="detail.like_count">
							{{detail.like_count}}次赞
						</view>
					</view>
				</view>
			</view>
		</view>
		<!--  -->
	</view>
</template>

<script>
	export default {
		name:"compDetail",
		props:["detail"],
		data() {
			return {
				totalPic:0,
				current:1,
			};
		},
		created(){
			this.totalPic = this.detail.images.length
			// console.log(this.detail.images.length)
		},
		computed:{
			disposeTime(){
				// 处理时间
				// console.log(this.detail.publishtime.split(" ")[0])
				return this.detail.publishtime.split(" ")[0]
			}
		},
		methods:{
			currentIndex(e){
				this.current = e.detail.current + 1
				
			}
		}
	}
</script>

<style lang="scss">
.comp_detail{
	padding-top: 130rpx;
	.de_banner{
		width: 100%;
		height: 1000rpx;
		position: relative;
		.swiper_list{
			width: 100%;
			height: 100%;
			.swiper_item{
				height: 100%;
				width: 100%;
				.item_pos{
					height: 100%;
					width: 100%;
					position: relative;
					.img{
						position: absolute;
						height: 100%;
						width: 100%;
						top: 0 !important;
						left: 0 !important;
						bottom: 0 !important;
						right: 0 !important;
						margin: auto !important;
					}
				}
				
			}
		}
		
		// btn
		.tips{
			position: absolute;
			bottom: 50rpx;
			width: 100%;
			margin: 0 auto;
			display: flex;
			justify-content: space-between;
			.selection_text{
				font-size: 16rpx;
				font-weight: bold;
				background-color: #FFC533;
				padding: 4rpx 10rpx;
				border-radius: 6rpx;
				margin-left: 30rpx;
			}
			.nums{
				font-size: 16rpx;
				color: #FFFFFF;
				background-color: rgba(0,0,0,.3);
				padding: 6rpx 20rpx;
				border-radius: 20rpx;
				margin-right: 30rpx;
			}
		}
	
	}
	
	// 内容区
	.de_content{
		width: 94%;
		margin: 0 auto;
		.con_title{
			font-weight: 600;
			font-size: 34rpx;
			padding: 20rpx 0;
		}
		.con_topic{
			.topic{
				display: flex;
				align-items: center;
				.img{
					width: 26rpx;
					height: 26rpx;
				}
				.txt{
					line-height: 1.4;
					
				}
				.txt_active{
					font-weight: bold;
				}
			}
			// 时间 点赞 收藏 
			.topic_time{
				display: flex;
				justify-content: space-between;
				font-size: 20rpx;
				color: #999999;
				font-weight: bold;
				padding: 20rpx 0;
				.time{}
				.time_dot{
					// width: 30%;
					display: flex;
					// justify-content: space-between;
					.collection{
						// margin-left: 10rpx;
					}
					.dots{
						margin-left: 10rpx;
					}
				}
				
			}
		}
	}
}
</style>
